package test.lu.materidesign;


/**
 * Created by Administrator on 2016/10/27 0027.
 */
public class PathPoint {
    public static final int PP_NONE = 0;
    public static final int PP_LINETO = 1;
    public static final int PP_QUADTO = 2 ;
    public static final int PP_CUBICTO = 3;
    public static final int PP_MOVETO = 4;

    public float x, y;
    public float controlX1;
    public float controlY1;
    public float controlX2;
    public float controlY2;
    public float endX;
    public float endY;
    int type;


    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }


    public PathPoint() {

    }

    public PathPoint(int cmdType, int x, int y){
        if(PP_MOVETO == cmdType) {
            this.endX = x;
            this.endY = y;
            this.type = cmdType;
        }else if(PP_LINETO == cmdType){
            this.endX = x;
            this.endY = y;
            this.type = cmdType;
        }
    }

    public PathPoint(int cmdType, int controlX, int controlY, int endX, int endY){
        if(PP_QUADTO == cmdType) {
            this.controlX1 = controlX;
            this.controlY1 = controlY;
            this.endX = endX;
            this.endY = endY;
            this.type = cmdType;
        }
    }

    public PathPoint(int cmdType, int controlX1, int controlY1, int controlX2, int controlY2, int endX, int endY){
        if(PP_CUBICTO == cmdType) {
            this.controlX1 = controlX1;
            this.controlY1 = controlY1;
            this.controlX2 = controlX2;
            this.controlY2 = controlY2;
            this.endX = endX;
            this.endY = endY;
            this.type = cmdType;
        }
    }

    public static PathPoint moveTo(int x, int y){
        return new PathPoint(PP_MOVETO, x, y);
    }
    public static PathPoint lineTo(int x, int y){
        return new PathPoint(PP_LINETO, x, y);
    }

    public static PathPoint quadTo(int contolX, int controlY, int endX, int endY){
        return new PathPoint(PP_QUADTO, contolX, controlY, endX, endY);
    }

    public static PathPoint cubicTo(int contolX, int controlY, int contolX2, int controlY2, int endX, int endY){
        return new PathPoint(PP_CUBICTO, contolX, controlY, contolX2, controlY2, endX, endY);
    }

}
